<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="zh">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
  <title>管理系统</title>
  <link href="${pageContext.request.contextPath}/css/bootstrap.min.css" rel="stylesheet">
  <link href="${pageContext.request.contextPath}/js/bootstrap-select/bootstrap-select.min.css" rel="stylesheet">

  <link href="${pageContext.request.contextPath}/css/materialdesignicons.min.css" rel="stylesheet">
  <link href="${pageContext.request.contextPath}/css/style.min.css" rel="stylesheet">
  <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
  <script type="text/javascript" src="${pageContext.request.contextPath}/layer/layer.js"></script>
  <script>
    <c:if test="${info != null}">
    layer.ready(function(){
      layer.open({
        type: 1,
        area : ["150px", "75px"],
        closeBtn: 0, //不显示关闭按钮
        title : false,
        anim: 6,
        shadeClose: true, //开启遮罩关闭
        time: 2000,
        content:  '<div style="margin: auto; width: 100%; height: 100%" class="alert alert-success" role="alert"><h3 style="text-align: center">${info}</h3></div>',
        success: function () {

        }
      });
    });
    </c:if>
  </script>
  <style>
    input{height: 70px}
  </style>
</head>

<body data-theme="translucent">


<div class="container">
    <div class="row">
      <br>
      <div class="text-center">
        <img src="${pageContext.request.contextPath}/images/modify.png" alt="">
      </div>
      <br>
          <form action="#" method="post" class="form-horizontal" id="form">
            <div class="form-group">
                <label class="col-xs-4 control-label text-right" for="name">姓名:</label>
                <div class="col-xs-7">
                  <input class="form-control text-center" type="text" id="name" name="name" value="${teacher.name}" disabled>
                  <input class="form-control text-center" type="hidden"  name="name" value="${teacher.name}">
                </div>
            </div>
              <br>
            <div class="form-group">
              <label class="col-xs-4 control-label text-right" for="gander">性别:</label>
              <div class="col-xs-7">
                <input class="form-control text-center" type="text" id="gander" name="gander" value="${teacher.gander}" disabled>
              </div>
            </div>
              <br>
            <div class="form-group">
              <label class="col-xs-4 control-label text-right" for="idcard">身份证号:</label>
              <div class="col-xs-7">
                <input class="form-control text-center" type="text" id="idcard" name="idcard" value="${teacher.idcard}" disabled>
              </div>
            </div>
              <br>
            <div class="form-group">
              <label class="col-xs-4 control-label text-right" for="title">职称:</label>
              <div class="col-xs-7">
                <select class="selectpicker form-control text-center" name="title" id="title" data-with="auto" data-maxwidth="270px" data-width="270px">
                  <c:forEach var="title" items="${titleList}" varStatus="id">
                    <c:if test="${title.title != teacher.title}">
                    <option class="text-center" value="${id.count}">${title.title}</option>
                    </c:if>
                    <c:if test="${title.title == teacher.title}">
                      <option selected class="text-center" value="0">${teacher.title}</option>
                    </c:if>
                  </c:forEach>
                </select>
              </div>
            </div>
            <br>
            <div class="form-group">
              <label class="col-xs-4 control-label text-right" for="college">学院:</label>
              <div class="col-xs-7">
                <select class="selectpicker form-control text-center" name="college" id="college" data-maxwidth="270px" data-width="270px">
                  <c:forEach var="college" items="${collegeList}" varStatus="id">
                    <c:if test="${college.college != teacher.college}">
                    <option class="text-center" value="${college.collegeId}">${college.college}</option>
                    </c:if>
                    <c:if test="${college.college == teacher.college}">
                      <option selected class="text-center" value="0">${teacher.college}</option>
                    </c:if>
                  </c:forEach>
                </select>
              </div>
            </div>
            <br>
            <div class="form-group">
              <label class="col-xs-4 control-label text-right" for="profession">研究方向:</label>
              <div class="col-xs-7">
                <input class="form-control text-center" type="text" id="profession" name="profession" value="${teacher.profession}">
              </div>
            </div>
            <br>
            <div class="form-group">
              <label class="col-xs-4 control-label text-right" for="email">邮箱地址</label>
              <div class="col-xs-7">
                <input class="form-control text-center" type="email" id="email" name="email" value="${teacher.email}">
              </div>
            </div>
            <br>
            <div class="form-group">
              <button type="button" id="submit" class="btn btn-label btn-warning col-xs-offset-3 col-xs-7"><label><i class="mdi mdi-account-convert"></i></label>确认修改</button>
            </div>
          </form>
    </div>
  </div>

<input type="hidden" id="targetEmail" value="${teacher.email}">
<input type="hidden" id="targetTitle" value="0">
<input type="hidden" id="targetCollege" value="0">
<input type="hidden" id="targetProfession" value="${teacher.profession}">



<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/layer/layer.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/bootstrap.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/bootstrap-select/bootstrap-select.js"></script>

<script type="text/javascript" src="${pageContext.request.contextPath}/js/perfect-scrollbar.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/main.min.js"></script>

<script>
   $("#submit").on("click", function () {
     // alert("11")
    var college = $("#college").val();
    var title = $("#title").val();
    var profession = $("#profession").val();
    var email = $("#email").val();
    var targetEmail = $("#targetEmail").val();
    var targetTitle = $("#targetTitle").val();
    var targetProfession = $("#targetProfession").val();
    var targetCollege = $("#targetCollege").val();
   //  alert(college);
   // alert(title)
   // alert(profession)
   // alert(email)
     if (college == targetCollege && title == targetTitle && profession == targetProfession && email == targetEmail)
    {
      layer.open({
        type: 1,
        area : ["200px", "60px"],
        closeBtn: 0, //不显示关闭按钮
        title : false,
        anim: 6,
        shadeClose: true, //开启遮罩关闭
        time: 2000,
        content:  '<div style="margin: auto; width: 100%; height: 100%" class="alert alert-success" role="alert"><h4 class="text-center">信息并未更改！</h4></div>',
        success: function () {
        }
      });
      return false;
    }
     $.ajax({
       type:"POST",
       url:"${pageContext.request.contextPath}/tea/modify",
       data: $("#form").serialize(),
       dataType:"json",
       complete: function () {
         layer.open({
           type: 1,
           area : ["150px", "75px"],
           closeBtn: 0, //不显示关闭按钮
           title : false,
           anim: 6,
           shadeClose: true, //开启遮罩关闭
           time: 1000,
           content:  '<div style="margin: auto; width: 100%; height: 100%" class="alert alert-success" role="alert"><h4 style="text-align: center">修改成功</h4></div>'
         });
         setTimeout(function ()  {
           parent.location.reload(); // 父页面刷新
           var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
           parent.layer.close(index);
         }, 1000)

       }
     });

   });
</script>
</body>
</html>